package com.toyota.toyotaownerspoc.main;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;

public class GpsLocaton implements LocationListener
{
	protected LocationManager locationManager;
	protected LocationListener locationListener;
	private double latitude = 0.0;
	private double longitude = 0.0;

	
	public GpsLocaton(){
		super();
	}
	public GpsLocaton(LocationManager lm){
		super();
		this.locationManager = lm;
	}
	
	@Override
	public void onLocationChanged(Location location) {

	   this.latitude = location.getLatitude();
	   this.longitude = location.getLongitude();
	}
	 
	public LocationManager getLocationManager(){
		return this.locationManager;
	}
	
	public void updateLocation(){
		locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);
		 Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
         if (location != null)
         {
             this.latitude = location.getLatitude();
             this.longitude = location.getLongitude();

         } 
	}
	
	@Override
	public void onProviderDisabled(String provider) {
	Log.d("Latitude","disable");
	}
	 
	@Override
	public void onProviderEnabled(String provider) {
	Log.d("Latitude","enable");
	}
	 
	@Override
	public void onStatusChanged(String provider, int status, Bundle extras) {
	Log.d("Latitude","status");
	}
	
	public double getLatitude()
	{
	return this.latitude;
	}
	
	public double getLongitude()
	{
		return this.longitude;
	}

}
